// MyHotKeyCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "ansieditor.h"
#include "MyHotKeyCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyHotKeyCtrl

CMyHotKeyCtrl::CMyHotKeyCtrl()
{
	nItem = -1;
}

CMyHotKeyCtrl::~CMyHotKeyCtrl()
{
}


BEGIN_MESSAGE_MAP(CMyHotKeyCtrl, CHotKeyCtrl)
	//{{AFX_MSG_MAP(CMyHotKeyCtrl)
	ON_WM_KEYUP()
	ON_WM_KILLFOCUS()
	ON_WM_SETFOCUS()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyHotKeyCtrl message handlers

void CMyHotKeyCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CHotKeyCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
	if(nChar == VK_RETURN)
	{
		GetParent()->SendMessage(WM_COMMAND, GetDlgCtrlID());
	}
}

void CMyHotKeyCtrl::OnKillFocus(CWnd* pNewWnd) 
{
	GetParent()->SendMessage(WM_COMMAND, GetDlgCtrlID());
	CHotKeyCtrl::OnKillFocus(pNewWnd);
	ShowWindow(SW_HIDE);
}

void CMyHotKeyCtrl::OnSetFocus(CWnd* pOldWnd) 
{
	GetHotKey(m_key, m_wModifiers);
	CHotKeyCtrl::OnSetFocus(pOldWnd);
}

void CMyHotKeyCtrl::Reset()
{
	SetHotKey(m_key, m_wModifiers);
}
